/*
SCUMMActionBar: This is the handler of the actions bar.
Controls the current selected action and contains the status bar
wich shows it.
*/
import SCUMMGameControl.SCUMMActionDescriptor;
import SCUMMCore.*;
class SCUMMGameControl.SCUMMActionBar extends SCUMMObject{
	public var nCurrentAction:Number;
	public var oActionParameter1:SCUMMObject;
	public var oActionParameter2:SCUMMObject;
	
	public function SCUMMActionBar(pmcActionBar:MovieClip){
		this.mc = pmcActionBar;
		nCurrentAction = 0;
		//this is very important, because "this" is not visible from
		//functions defined in constructor.
		var oSelfReference:SCUMMActionBar =  this;
		this.mc.onEnterFrame = function(){
			oSelfReference.updateStatusBar();
		};
	}
	
	private function updateStatusBar(){
		if(oActionParameter1!=undefined)
			writeOnStatusBar(SCUMMActionDescriptor.getStatusText(nCurrentAction)+" "+oActionParameter1.name);
		else
			writeOnStatusBar(SCUMMActionDescriptor.getStatusText(nCurrentAction));
		
	}
	
	public function writeOnStatusBar(psTextToWrite:String){
		this.mc.statusBar.text = psTextToWrite;
	}
	
	public function setCurrentAction(nCurrentAction:Number):Void {
		this.nCurrentAction = nCurrentAction;
		updateStatusBar();
	}
	public function getCurrentAction():Number {
		return this.nCurrentAction;
	}
	public function getOActionParameter1():SCUMMObject {
		return oActionParameter1;
	}

	public function setOActionParameter1(oActionParameter1:SCUMMObject):Void {
		this.oActionParameter1 = oActionParameter1;
		updateStatusBar();
	}

	public function getOActionParameter2():SCUMMObject {
		return oActionParameter2;
	}

	public function setOActionParameter2(oActionParameter2:SCUMMObject):Void {
		this.oActionParameter2 = oActionParameter2;
		updateStatusBar();
	}

}